package com.chl.legou.seckill.controller;

import com.chl.legou.core.controller.BaseController;
import com.chl.legou.seckill.po.SeckillGoods;
import com.chl.legou.seckill.service.ISeckillGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author chlong
 * @date 2022/7/29
 */
@RestController
@RequestMapping("/seckill-goods")
@CrossOrigin
public class SeckillGoodsController extends BaseController<ISeckillGoodsService, SeckillGoods> {

    @Autowired
    private ISeckillGoodsService seckillGoodsService;

    /**
     * 通过时间获取列表
     * @param time
     * @return
     */
    @RequestMapping("/list/{time}")
    public List<SeckillGoods> list(@PathVariable("time") String time){
        List<SeckillGoods> seckillGoods = seckillGoodsService.list(time);
        for (SeckillGoods seckillGood : seckillGoods) {
            System.out.println("id是:"+seckillGood.getId());
        }
        return seckillGoods;
    }

    @RequestMapping("/one")
    public SeckillGoods one(String time,Long id){
        return seckillGoodsService.one(time, id);
    }
}
